
package com.x52im.rbchat.utils;

import android.content.Context;
import android.media.MediaPlayer;

import com.x52im.rbchat.R;
import com.eva.android.MediaPlayerHelper;

/**
 * 提示音播放实用类。
 *
 * @author JackJiang
 * @since 1.0
 */
public class PromtHelper {

    public static void toJifenPromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_tojifen);
    }

    public static void voiceRecordingPromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_voice_recording);
    }

    public static void voiceSendPromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_voice_send);
    }

    public static void voiceStopedPromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_voice_stoped);
    }

    /**
     * 播放好友添加成功后的提示音.
     *
     * @param context
     */
    public static void newFriendAddSucessPromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_new_friend_add_sucess);
    }

//
//	public static void offlinePromt(Context context)
//	{
//		if (PreferencesToolkits.isAPPMsgToneOpen(context))
//			MediaPlayerHelper.getInstance(context).play(R.raw.audio_chat_offline);
//	}

    public static void tixintPromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_prompt);
    }

    public static void messagePromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_msg);
    }

    public static void playendPromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_playend);
    }

    /**
     * 返回实时语音呼叫提示音的MediaPlayer对象。
     *
     * @param context 上下文
     * @param uid     聊天对方的uid，本参数当前仅用于读取"消息免打扰"设置，别无他用
     * @return 如果成功或允许提示音则正常返回，否则返回null
     */
    public static MediaPlayer callingPromt(Context context, String uid) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context)) {
            MediaPlayer mp = MediaPlayerHelper.getInstance(context).createMediaPlayer(R.raw.audio_calling);
            mp.setLooping(true);
            mp.start();
            return mp;
        }
        return null;
    }

    /**
     * 返回实时视频呼叫提示音的MediaPlayer对象。
     *
     * @param context 上下文
     * @param uid     聊天对方的uid，本参数当前仅用于读取"消息免打扰"设置，别无他用
     * @return 如果成功或允许提示音则正常返回，否则返回null
     */
    public static MediaPlayer calling2Promt(Context context, String uid) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context)) {
            MediaPlayer mp = MediaPlayerHelper.getInstance(context).createMediaPlayer(R.raw.audio_calling2);
            mp.setLooping(true);
            mp.start();
            return mp;
        }
        return null;
    }

    public static void rapidDidongdidongdiPromt(Context context) {
        if (PreferencesToolkits.isAPPMsgToneOpen(context))
            MediaPlayerHelper.getInstance(context).play(R.raw.audio_rapid_didongdidongdi);
    }
}
